{% extends 'layout.html' %}

{% block maincontent %}
    <h1 class="text-center">
        诗歌首页
    </h1>

    <table class='table table-striped table-bordered table-hover'>
        <thead>
            <tr>
                <th>诗歌标题</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <!-- 该模板接收的数据为poems诗歌数据列表 -->
            {% for poem in poems %}
                <tr>
                    <td> 
                    <a href="{% url 'poem:detail' poem.id %}">
                        {{ poem.title }} 
                    </a>
                    </td>
                    <td> 
                        <a class='btn btn-danger btn-sm' href="{% url 'poem:delete' poem.id %}"> 删除 </a>
                        <a class='btn btn-success btn-sm' href="{% url 'poem:edit' poem.id %}"> 修改 </a>
                    </td>
                </tr>

            {% endfor %}
        </tbody>
        
    </table>
    
    <a href="{% url 'poem:add' %}">添加诗歌</a>
{% endblock %}
    

